package com.gdth.bank.presenter;

import java.util.List;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

import com.gdth.bank.model.DzCpKhXxFjModel;
import com.gdth.bank.view.DzCpKhXxFjView;
import com.gdth.database.bean.TAppFjxxb;;

public class DzCpKhXxFjPresenter {
	private DzCpKhXxFjView  mDzCpKhXxFjView;
	private DzCpKhXxFjModel mDzCpKhXxFjModel;
	public int loadDzCpKhXx = 101;
public DzCpKhXxFjPresenter(DzCpKhXxFjView mDzCpKhXxFjView) {
		
		this.mDzCpKhXxFjView = mDzCpKhXxFjView;
		mDzCpKhXxFjModel = new DzCpKhXxFjModel();
	}
public void saveDzcpkhxxfj(TAppFjxxb mTAppFjxxb){
	mDzCpKhXxFjModel.saveDzcpkhxxfj(mTAppFjxxb)
		.subscribeOn(Schedulers.io())
		.unsubscribeOn(Schedulers.io())
		.observeOn(AndroidSchedulers.mainThread())
		.subscribe(new Subscriber<TAppFjxxb>(){

			@Override
			public void onCompleted() {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void onError(Throwable arg0) {
				// TODO Auto-generated method stub
				mDzCpKhXxFjView.showMessage("保存失败");
			}

			@Override
			public void onNext(TAppFjxxb arg0) {
				// TODO Auto-generated method stub
			}
			
		});
}
public void getDzcpkhxxfj(String uuid){
	mDzCpKhXxFjModel.getDzcpkhxxfl(uuid)
	.subscribeOn(Schedulers.io())
	.unsubscribeOn(Schedulers.io())
	.observeOn(AndroidSchedulers.mainThread())
	.subscribe(new Subscriber<List<TAppFjxxb>>(){

		@Override
		public void onCompleted() {
			// TODO Auto-generated method stub
			mDzCpKhXxFjView.hideProgressDialog();
		}

		@Override
		public void onError(Throwable arg0) {
			// TODO Auto-generated method stub
			mDzCpKhXxFjView.showMessage("获取失败");
		}

		@Override
		public void onNext(List<TAppFjxxb> arg0) {
			// TODO Auto-generated method stub
		  if (arg0 != null){
			  mDzCpKhXxFjView.updateViewFj(loadDzCpKhXx, arg0);
			}
		}});
}

}
